<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="ex.js"></script>
</head>
<body>
        <button id="active">Click me</button>

        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
        <script>


            $(function(){

                var idleTime;
                $('#active').click(function(){
                    clearTimeout(idleTime);
                    idleTime =setTimeout(function(){alert('inactive for 2 seconds');},2000);

                });
            });



            //$(function(){
         //$('body').hover(function(){alert('login')});
         // when(hover<2000);
         // alert('please login');
       //});
        </script>
</body>
</html>